import java.util.HashMap;
import java.util.Map;

/**
 * @author 甜圆
 * @version v1.0.1
 * @date 2025/8/14 15:57
 * @package PACKAGE_NAME
 * @copyright 甜圆
 */ // 扑克牌类
class Card implements Comparable<Card> {
    private String suit;  // 花色
    private String rank;  // 点数
    private int weight;   // 权重，用于比较大小

    public Card(String suit, String rank, int weight) {
        this.suit = suit;
        this.rank = rank;
        this.weight = weight;
    }
    // 重写比较方法，用于排序
    @Override
    public int compareTo(Card other) {
        // 先比较权重，权重相同则比较花色
        if (this.weight != other.weight) {
            return Integer.compare(this.weight, other.weight);
        } else {
            // 定义花色的优先级：黑桃>红桃>方块>梅花
            Map<String, Integer> suitOrder = new HashMap<>();
            suitOrder.put("♠", 4);
            suitOrder.put("♥", 3);
            suitOrder.put("♦", 2);
            suitOrder.put("♣", 1);

            return Integer.compare(suitOrder.get(this.suit), suitOrder.get(other.suit));
        }
    }

    @Override
    public String toString() {
        return suit + rank;
    }
}
